﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QntPlatform.BinanceApi.DApi
{
    public partial class DApiClient
    {

        // public Balance[] GetAccount()
        // {
        //     return CreateReq(Prefix + "account").Get<Balance[]>().CheckResp(log);
        // }

    }
    public class AccountInformation
    {

        private bool? canDeposit;

        private bool? canTrade;

        private bool? canWithdraw;

        private decimal feeTier;

        private decimal maxWithdrawAmount;

        private decimal totalInitialMargin;

        private decimal totalMaintMargin;

        private decimal totalMarginBalance;

        private decimal totalOpenOrderInitialMargin;

        private decimal totalPositionInitialMargin;

        private decimal totalUnrealizedProfit;

        private decimal totalWalletBalance;

        private long? updateTime;

        private IList<Asset> assets;

        private IList<Position> positions;

        public virtual bool? CanDeposit
        {
            get
            {
                return canDeposit;
            }
            set
            {
                this.canDeposit = value;
            }
        }


        public virtual bool? CanTrade
        {
            get
            {
                return canTrade;
            }
            set
            {
                this.canTrade = value;
            }
        }


        public virtual bool? CanWithdraw
        {
            get
            {
                return canWithdraw;
            }
            set
            {
                this.canWithdraw = value;
            }
        }


        public virtual decimal FeeTier
        {
            get
            {
                return feeTier;
            }
            set
            {
                this.feeTier = value;
            }
        }


        public virtual decimal MaxWithdrawAmount
        {
            get
            {
                return maxWithdrawAmount;
            }
            set
            {
                this.maxWithdrawAmount = value;
            }
        }


        public virtual decimal TotalInitialMargin
        {
            get
            {
                return totalInitialMargin;
            }
            set
            {
                this.totalInitialMargin = value;
            }
        }


        public virtual decimal TotalMaintMargin
        {
            get
            {
                return totalMaintMargin;
            }
            set
            {
                this.totalMaintMargin = value;
            }
        }


        public virtual decimal TotalMarginBalance
        {
            get
            {
                return totalMarginBalance;
            }
            set
            {
                this.totalMarginBalance = value;
            }
        }


        public virtual decimal TotalOpenOrderInitialMargin
        {
            get
            {
                return totalOpenOrderInitialMargin;
            }
            set
            {
                this.totalOpenOrderInitialMargin = value;
            }
        }


        public virtual decimal TotalPositionInitialMargin
        {
            get
            {
                return totalPositionInitialMargin;
            }
            set
            {
                this.totalPositionInitialMargin = value;
            }
        }


        public virtual decimal TotalUnrealizedProfit
        {
            get
            {
                return totalUnrealizedProfit;
            }
            set
            {
                this.totalUnrealizedProfit = value;
            }
        }


        public virtual decimal TotalWalletBalance
        {
            get
            {
                return totalWalletBalance;
            }
            set
            {
                this.totalWalletBalance = value;
            }
        }


        public virtual long? UpdateTime
        {
            get
            {
                return updateTime;
            }
            set
            {
                this.updateTime = value;
            }
        }


        public virtual IList<Asset> Assets
        {
            get
            {
                return assets;
            }
            set
            {
                this.assets = value;
            }
        }


        public virtual IList<Position> Positions
        {
            get
            {
                return positions;
            }
            set
            {
                this.positions = value;
            }
        }


        public class Asset
        {

            public string asset { get; set; }

            private decimal initialMargin;

            private decimal maintMargin;

            private decimal marginBalance;

            private decimal maxWithdrawAmount;

            private decimal openOrderInitialMargin;

            private decimal positionInitialMargin;

            private decimal unrealizedProfit;



            public virtual decimal InitialMargin
            {
                get
                {
                    return initialMargin;
                }
                set
                {
                    this.initialMargin = value;
                }
            }


            public virtual decimal MaintMargin
            {
                get
                {
                    return maintMargin;
                }
                set
                {
                    this.maintMargin = value;
                }
            }


            public virtual decimal MarginBalance
            {
                get
                {
                    return marginBalance;
                }
                set
                {
                    this.marginBalance = value;
                }
            }


            public virtual decimal MaxWithdrawAmount
            {
                get
                {
                    return maxWithdrawAmount;
                }
                set
                {
                    this.maxWithdrawAmount = value;
                }
            }


            public virtual decimal OpenOrderInitialMargin
            {
                get
                {
                    return openOrderInitialMargin;
                }
                set
                {
                    this.openOrderInitialMargin = value;
                }
            }


            public virtual decimal PositionInitialMargin
            {
                get
                {
                    return positionInitialMargin;
                }
                set
                {
                    this.positionInitialMargin = value;
                }
            }


            public virtual decimal UnrealizedProfit
            {
                get
                {
                    return unrealizedProfit;
                }
                set
                {
                    this.unrealizedProfit = value;
                }
            }

        }

        /** <summary>
          "positions": [  // 头寸，将返回所有市场symbol。
            //根据用户持仓模式展示持仓方向，即双向模式下只返回BOTH持仓情况，单向模式下只返回 LONG 和 SHORT 持仓情况
            {
                "symbol": "BTCUSDT",  // 交易对
                "initialMargin": "0",   // 当前所需起始保证金(基于最新标记价格)
                "maintMargin": "0", //维持保证金
                "unrealizedProfit": "0.00000000",  // 持仓未实现盈亏
                "positionInitialMargin": "0",  // 持仓所需起始保证金(基于最新标记价格)
                "openOrderInitialMargin": "0",  // 当前挂单所需起始保证金(基于最新标记价格)
                "leverage": "100",  // 杠杆倍率
                "isolated": true,  // 是否是逐仓模式
                "entryPrice": "0.00000",  // 持仓成本价
                "maxNotional": "250000",  // 当前杠杆下用户可用的最大名义价值
                "positionSide": "BOTH",  // 持仓方向
                "positionAmt": "0"      // 持仓数量
            }
        ]
        </summary>
         */
        public class Position
        {

            private bool? isolated;

            private decimal leverage;

            private decimal initialMargin;

            private decimal maintMargin;

            private decimal openOrderInitialMargin;

            private decimal positionInitialMargin;

            private string symbol;

            private decimal unrealizedProfit;


            private string maxNotional;

            private string positionSide;

            public decimal positionAmt { get; set; }
            public virtual bool? Isolated
            {
                get
                {
                    return isolated;
                }
                set
                {
                    this.isolated = value;
                }
            }


            public virtual decimal Leverage
            {
                get
                {
                    return leverage;
                }
                set
                {
                    this.leverage = value;
                }
            }


            public virtual decimal InitialMargin
            {
                get
                {
                    return initialMargin;
                }
                set
                {
                    this.initialMargin = value;
                }
            }


            public virtual decimal MaintMargin
            {
                get
                {
                    return maintMargin;
                }
                set
                {
                    this.maintMargin = value;
                }
            }


            public virtual decimal OpenOrderInitialMargin
            {
                get
                {
                    return openOrderInitialMargin;
                }
                set
                {
                    this.openOrderInitialMargin = value;
                }
            }


            public virtual decimal PositionInitialMargin
            {
                get
                {
                    return positionInitialMargin;
                }
                set
                {
                    this.positionInitialMargin = value;
                }
            }


            public virtual string Symbol
            {
                get
                {
                    return symbol;
                }
                set
                {
                    this.symbol = value;
                }
            }


            public virtual decimal UnrealizedProfit
            {
                get
                {
                    return unrealizedProfit;
                }
                set
                {
                    this.unrealizedProfit = value;
                }
            }


            public virtual decimal EntryPrice
            {
                get; set;
            }


            public virtual string MaxNotional
            {
                get
                {
                    return maxNotional;
                }
                set
                {
                    this.maxNotional = value;
                }
            }


            public virtual string PositionSide
            {
                get
                {
                    return positionSide;
                }
                set
                {
                    this.positionSide = value;
                }
            }



        }


    }



}
